<script Language="JavaScript">
<!--
function controllo(form){
if(!confirm('Sei sicuro?'))
	return (false);
if (form.tipologia.value == ""){
   alert("ATTENZIONE! Tipo abbonamento mancante");
   form.tipologia.focus();
   return (false);
}
if (form.costo.value == ""){
   alert("ATTENZIONE! Costo abbonamento mancante");
   form.costo.focus();
   return (false);
}
return (true);
}
//-->
</script>
<?
$day = "";
$month = "";
$year = "";

if($this->_dt_inizio!=null)
{
	$day = substr($this->_dt_pagamento, 8, 2);
	$month = substr($this->_dt_pagamento, 5, 2);
	$year = substr($this->_dt_pagamento, 0, 4);
	$dt_pagamento_format = $day."/".$month."/".$year;
}
else
	$dt_pagamento_format = "";
	
if($this->_dt_inizio!=null)
{
	$day = substr($this->_dt_inizio, 8, 2);
	$month = substr($this->_dt_inizio, 5, 2);
	$year = substr($this->_dt_inizio, 0, 4);
	$dt_inizio_format = $day."/".$month."/".$year;
}
else
	$dt_inizio_format = "";
	
if($this->_dt_fine!=null)
{
	$day = substr($this->_dt_fine, 8, 2);
	$month = substr($this->_dt_fine, 5, 2);
	$year = substr($this->_dt_fine, 0, 4);
	$dt_fine_format = $day."/".$month."/".$year;
}
else
	$dt_fine_format = "";
?>

<table width="100%"  class="table table-striped table-bordered table-condensed">
        <tr>
        <td>        
		<form action="/admin/action/contratto_action.php" method="POST" onSubmit='return controllo(this)'>
        <fieldset>
    	<legend>Contratto di <?php echo $this->_username; ?></legend>

			Abbonamento:
            <select name="tipologia" class="input_form_medium ui-corner-all">
                  <option value="" <?=($this->_tipologia == "" ? "selected" : "")?>>Non definito</option>
                  <option value="S" <?=($this->_tipologia == "S" ? "selected" : "")?>>Smart</option>
                  <option value="T" <?=($this->_tipologia == "T" ? "selected" : "")?>>Top</option>
                  <option value="L" <?=($this->_tipologia == "L" ? "selected" : "")?>>Luxury</option>
           	</select>&nbsp;&nbsp;
            durata&nbsp;<select name="durata" id="durata" class="input_form ui-corner-all">
                            <option value="1m" <?=($this->_durata == "1m" ? "selected" : "")?> selected>1 mese</option>
                            <option value="2m" <?=($this->_durata == "2m" ? "selected" : "")?>>2 mesi</option>
                            <option value="2s" <?=($this->_durata == "2s" ? "selected" : "")?>>2 settimane</option>
                            <option value="1mbanner" <?=($this->_durata == "1mbanner" ? "selected" : "")?>>1 mese+banner</option>
                            <option value="2mbanner" <?=($this->_durata == "2mbanner" ? "selected" : "")?>>2 mesi+banner</option>
                            <option value="4mbanner" <?=($this->_durata == "4mbanner" ? "selected" : "")?>>4 mesi+banner</option>
                            <option value="2sbanner" <?=($this->_durata == "2sbanner" ? "selected" : "")?>>2 settimane+banner</option>
							<option value="gratis" <?=($this->_durata == "gratis" ? "selected" : "")?>>7 giorni di prova</option>
                        </select>&nbsp;&nbsp;
            costo <input type="text" name="costo" id="costo" class="input_form_medium ui-corner-all" value="<?php echo $this->_costo; ?>"/>&nbsp;&nbsp;
            sconto <input type="text" name="sconto" id="sconto" class="input_form_medium ui-corner-all" value="<?php echo $this->_sconto; ?>"/>		<br><br>	
			
            Pagamento&nbsp;
            <input type="text" class="input_form_medium ui-corner-all" name="dt_pagamento" id="datepicker" value="<?php echo $dt_pagamento_format; ?>" maxlength="10">&nbsp;
            da&nbsp;
            <input type="text" class="input_form_medium ui-corner-all" name="dt_inizio" id="datepicker2" value="<?php echo $dt_inizio_format; ?>" maxlength="10">&nbsp;
            a&nbsp;<input type="text" class="input_form_medium ui-corner-all" name="dt_fine" id="datepicker3" value="<?php echo $dt_fine_format; ?>" maxlength="10"><br><br>            
			
			Note:<br>
			<textarea name="note" class="input_form_big ui-corner-all" maxlength="" cols="70" rows="3" ><?php echo $this->_note;?></textarea>&nbsp;<br>max 1.000 caratteri<br><br>
            <input type="hidden" value="<?php echo $this->_id_contratto; ?>" name="id" />
            <input type="hidden" value="<?php echo $this->_id_abbonamento; ?>" name="id_abbonamento" />
			<input type="submit" value="Salva" name="salvaContratto" class="btn" />&nbsp;
			<input type="submit" value="Elimina" name="eliminaContratto" class="btn" />
		</fieldset>
		</form>
        </td>
      </tr>
    </table>